﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Transport
{
    public partial class category : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected string GetService(string maDichVu)
        {
            string html = null;
            DichVuControl dv = new DichVuControl();
            List<dich_vu> list = dv.listAll();
            foreach (dich_vu dichVu in list)
            {
                if (maDichVu == dichVu.id_dich_vu)
                    html += "<li><div><a class=\"selected\" href=\"./HireCars.aspx?madichvu=" + dichVu.id_dich_vu + "\">" + dichVu.ten_dich_vu + "</a></div></li>";
                else
                    html += "<li><div><a href=\"./HireCars.aspx?madichvu=" + dichVu.id_dich_vu + "\">" + dichVu.ten_dich_vu + "</a></div></li>";
            }
            return html;
        }
        protected string getCarByHangXe(string hangXe,int Page)
        {
            string html = null;
            XeControl banggiaLT = new XeControl();
            BangGiaTrongNgayControl bangGia = new BangGiaTrongNgayControl();
            html += "<div class=\"moduletable \"><div class=\"box-heading\">"
                + "<div class=\"box-heading1\">Danh sách xe</div>"
            + "</div>";
            html += "<div class=\"moduletable_content\">"
            + "<div id=\"icecarousel140\" class=\"ice-carousel\">"
                    + "<div class=\"ice-main-wapper\">";
            List<BGTLTentity> bangGiaLTs = banggiaLT.listAllByIDHangXe(hangXe,(Page-1)*5,5);
            foreach (BGTLTentity item in bangGiaLTs)
            {
                html += GenHtml.genBangGiaLT(item);
            }
            List<BangGiaTrongNgayNew> banggias = bangGia.GetBangGiaByIDHangXe(hangXe, (Page - 1) * 5, 5);
            foreach (BangGiaTrongNgayNew item in banggias)
            {
                html += GenHtml.getBangGiaNgay(item);
            }
            int r1 = banggiaLT.CountAllByIDHangXe(hangXe);
            int r2 = bangGia.GetCountBangGiaByIDHangXe(hangXe);
            html += "</div></div></div></div>";
            string page = GenHtml.Pagination(Page, r1 + r2, "HireCars.aspx?hangxe=" + hangXe);
            html += "<div class=\"pagination\">" + page + "</div>";
            return html;
        }
        protected string getCar(string idService,int Page)
        {
            string html = null;
            DichVuControl dv = new DichVuControl();
            BangGiaTrongNgayControl bangGia = new BangGiaTrongNgayControl();
            XeControl banggiaLT = new XeControl();
            dich_vu dichVu = dv.findByID(idService);
            if (dichVu != null)
            {
                html += "<div class=\"moduletable \"><div class=\"box-heading\">"
                    + "<div class=\"box-heading1\">" + dichVu.ten_dich_vu + "</div>"
                + "</div>";
                html += "<div class=\"moduletable_content\">"
                + "<div id=\"icecarousel140\" class=\"ice-carousel\">"
                        + "<div class=\"ice-main-wapper\">";
                int r1 = 0;
                if (dichVu.id_dich_vu == "0")
                {
                    r1 = banggiaLT.CountBGLTRecord();
                    List<BGTLTentity> bangGiaLTs = banggiaLT.listAllByRoute((Page-1)*5,5);
                    foreach (BGTLTentity item in bangGiaLTs)
                    {
                        html += GenHtml.genBangGiaLT(item);
                    }
                }
                else
                {

                    List<BangGiaTrongNgayNew> banggias = bangGia.GetBangGiaTrongNgayNew(dichVu.id_dich_vu, (Page - 1) * 5, 5);
                    r1 = bangGia.CountBGTGRecordBeService();
                    foreach (BangGiaTrongNgayNew item in banggias)
                    {
                        html += GenHtml.getBangGiaNgay(item);
                    }
                }
               
                html += "</div></div></div></div>";
                string page = GenHtml.Pagination(Page, r1, "HireCars.aspx?madichvu="+idService);
                html += "<div class=\"pagination\">" + page + "</div>";
            }

            return html;
        }
        protected string getCar(int Page)
        {
            string html = null;
            XeControl banggiaLT = new XeControl();
            BangGiaTrongNgayControl bangGia = new BangGiaTrongNgayControl();
            html += "<div class=\"moduletable \"><div class=\"box-heading\">"
                + "<div class=\"box-heading1\">Danh sách xe</div>"
            + "</div>";
            html += "<div class=\"moduletable_content\">"
            + "<div id=\"icecarousel140\" class=\"ice-carousel\">"
                    + "<div class=\"ice-main-wapper\">";
            List<BGTLTentity> bangGiaLTs = banggiaLT.listAllByRoute((Page - 1) * 5, 5);
            foreach (BGTLTentity item in bangGiaLTs)
            {
                html += GenHtml.genBangGiaLT(item);
            }
            List<BangGiaTrongNgayNew> banggias = bangGia.GetBangGiaTrongNgayNew((Page - 1) * 5, 5);
            foreach (BangGiaTrongNgayNew item in banggias)
            {
                html += GenHtml.getBangGiaNgay(item);
            }
            int r1 = banggiaLT.CountBGLTRecord();
            int r2 = bangGia.CountBGTGRecord();
            html += "</div></div></div></div>";
            string page = GenHtml.Pagination(Page,r1+r2, "Hirecars.aspx?");
            html += "<div class=\"pagination\">"+page+"</div>";
            return html;
        }
    }
}